/*
 * @Author: your name
 * @Date: 2020-10-26 14:40:19
 * @LastEditTime: 2020-11-05 19:13:20
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /crowd-funding/src/components/pages/HomePage/reducer.js
 */
export const homeData = function (
	state = {
		isLoading: false,
		storyPageData: {
			projectStoryNewDto: {},
		},
	},
	{ type, payload } = {}
) {
	switch (type) {
		case 'set:homeData': // 初始数据
			return { ...state, ...payload }

		default:
			return state
	}
}
export const errorData = function (
	state = {
		code: 0,
		message: '',
		img: '',
		reloadAction: 'reload:homeData',
	},
	{ type, payload } = {}
) {
	switch (type) {
		case 'set:errorData': // 故事页数据
			return { ...state, ...payload }

		default:
			return state
	}
}

export const dialogData = function (
	state = {
		isOpen: false,
	},
	{ type, payload } = {}
) {
	switch (type) {
		case 'open:dialog': // 是否弹窗
			return { ...state, ...payload }

		default:
			return state
	}
}
export const redoundItemData = function (
	state = {
		redoundItem: {},
		selected: false,
		count: 1,
	},
	{ type, payload } = {}
) {
	switch (type) {
		case 'set:redoundItem': // 去支持
			return { ...state, ...payload }
		default:
			return state
	}
}

// 图片处理结果
export const imageData = function (state = {}, { type, payload } = {}) {
	switch (type) {
		case 'save:image':
			return { ...state, ...payload }
		default:
			return state
	}
}

// 保存日历提醒状态

export const reminderStatus = function (state = null, { type, payload } = {}) {
	switch (type) {
		case 'save:reminderStatus':
			return payload
		default:
			return state
	}
}

// 保存滚动Top值
export const top = function (state = 0, { type, payload } = {}) {
	switch (type) {
		case 'save:top':
			return payload
		default:
			return state
	}
}
